package com.itheima.chapter08.set.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//map遍历
public class Mapdemo3 {
    public static void main(String[] args) {
        Map<String,String> map =new HashMap<>();
        map.put("张无忌","赵敏");
        map.put("郭靖","黄蓉");
        map.put("杨过","小龙女");
        map.put("钱钱","太子");
        //获取所有键值对对象
        Set<Map.Entry<String, String>> entrySet = map.entrySet();
        for (Map.Entry<String, String> ss : entrySet) {
            String key = ss.getKey();
            String value = ss.getValue();
            System.out.println(key+ " "+value);
        }
        System.out.println("=================");
        //获取键集合
        Set<String> keySet = map.keySet();
        for (String key : keySet) {
            //根据建去找值
            String values = map.get(key);
            System.out.println(key+ " "+values);
        }
    }

}
